    <!-- aditional stylesheets -->
        <!-- datatables -->
            <link rel="stylesheet" href="template/js/lib/datatables/css/datatables_beoro.css">
            <link rel="stylesheet" href="template/js/lib/datatables/extras/TableTools/media/css/TableTools.css">


        <!-- datepicker -->
            <link rel="stylesheet" href="template/js/lib/bootstrap-datepicker/css/datepicker.css">

        <!--[if lte IE 8]><link rel="stylesheet" href="template/css/ie8.css"><![endif]-->
        <!--[if IE 9]><link rel="stylesheet" href="template/css/ie9.css"><![endif]-->
            
        <!--[if lt IE 9]>
            <script src="template/js/ie/html5shiv.min.js"></script>
            <script src="template/js/ie/respond.min.js"></script>
            <script src="template/js/lib/flot-charts/excanvas.min.js"></script>
        <![endif]-->

    <!-- main wrapper (without footer) -->    

        <!-- top bar -->
            <div class="container">
                <div class="w-box" id="n_datepicker">
                    <div class="w-box-content cnt_a">
                        <div class="row-fluid">
                            <div class="span4">
                                <label>Дата последнего расчета бонусов</label>
                                <strong>2013.04.24</strong>
                            </div>
                            <div class="span2">
                                <button id="start" type="submit" class="btn btn-beoro-3">Расчитать</button>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span12">
                        <div class="w-box">
                            <div class="w-box-header">
                                <h4>Детализация</h4>
                            </div>
                            <div class="w-box-content">
                                <table id="dt_table_tools3" class="table table-striped table-condensed">
                                    <thead>
                                        <tr>
                                            <th>№</th>
                                            <th>Номер телефона</th>
                                            <th>Комиссия агента в %</th>
                                            <th>Субагент если есть (его id)</th>
                                            <th>Комиссия субагента в %</th>
                                            <th>Сумма пополнения по номеру</th>
                                            <th>Сумма бонусов агента</th>
                                            <th>Сумма бонусов субагента</th>
                                            <th>Бонусы агента</th>
                                            <th>Бонусы субагента</th>
                                            <th>Дата последнего расчета бонусов</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                            <td>1</td>
                                            <td>37282861797</td>
                                            <td>10</td>
                                            <td><i class="splashy-contact_blue" style="margin-left:15px;"></i>test1</td>
                                            <td>3</td>
                                            <td>30.02</td>
                                            <td class="agent_bonus"></td>
                                            <td class="subagent_bonus"></td>
                                            <td class="all_agent_bonus">20</td>
                                            <td class="all_subagent_bonus">10</td>
                                            <td class="last_date"></td>
                                        </tr>
                                        <tr>
                                            <td>2</td>
                                            <td>37282861797</td>
                                            <td>10</td>
                                            <td><i class="splashy-contact_green" style="margin-left:15px;"></i>subagent1</td>
                                            <td>3</td>
                                            <td>15.02</td>
                                            <td class="agent_bonus"></td>
                                            <td class="subagent_bonus"></td>
                                            <td class="all_agent_bonus">30</td>
                                            <td class="all_subagent_bonus">20</td>
                                            <td class="last_date"></td>
                                        </tr>

                                    </tbody>                                                                    
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="footer_space"></div>

    <!-- footer --> 
        
        
    <!-- Common JS -->
        <!-- jQuery framework -->
            <script src="template/js/jquery.min.js"></script>
        <!-- bootstrap Framework plugins -->
            <script src="template/bootstrap/js/bootstrap.min.js"></script>
        <!-- top menu -->
            <script src="template/js/jquery.fademenu.js"></script>
        <!-- top mobile menu -->
            <script src="template/js/selectnav.min.js"></script>
        <!-- actual width/height of hidden DOM elements -->
            <script src="template/js/jquery.actual.min.js"></script>
        <!-- jquery easing animations -->
            <script src="template/js/jquery.easing.1.3.min.js"></script>
        <!-- power tooltips -->
            <script src="template/js/lib/powertip/jquery.powertip-1.1.0.min.js"></script>
        <!-- date library -->
            <script src="template/js/moment.min.js"></script>
        <!-- common functions -->
            <script src="template/js/beoro_common.js"></script>

        <!-- datatables -->
            <script src="template/js/lib/datatables/js/jquery.dataTables.min.js"></script>
        <!-- datatables column reorder -->
            <script src="template/js/lib/datatables/extras/ColReorder/media/js/ColReorder.min.js"></script>
        <!-- datatables column toggle visibility -->
            <script src="template/js/lib/datatables/extras/ColVis/media/js/ColVis.min.js"></script>
        <!-- datatable table tools -->
            <script src="template/js/lib/datatables/extras/TableTools/media/js/TableTools.min.js"></script>
            <script src="template/js/lib/datatables/extras/TableTools/media/js/ZeroClipboard.js"></script>
        <!-- datatables bootstrap integration -->
            <script src="template/js/lib/datatables/js/jquery.dataTables.bootstrap.min.js"></script>
        
        <!-- datepicker -->
            <script src="template/js/lib/bootstrap-datepicker/js/bootstrap-datepicker.min.js"></script>
            <script src="template/js/lib/date/date.format.js"></script>

            <script src="template/js/pages/beoro_datatables.js"></script>
            
            
<script type="text/javascript">
<!--
$(document).ready(function() {
    var d2 = new Date();
    d2.setDate(d2.getDate() - 1);
    d2 = dateFormat(d2, 'yyyy-mm-dd');
    var endDate=d2;
    
    $('.dataTables_filter input').each(function() {
        $(this).attr("placeholder", "Быстрый поиск");            
    });
    //start_find(endDate);            
});
$("#start").click(function() {
  sumTD();
});

function sumTD() {
    var d2 = new Date();
    d2.setDate(d2.getDate() - 1);
    d2 = dateFormat(d2, 'yyyy-mm-dd');
    var endDate=d2;
    $('#dt_table_tools3 tr').each(function() { 
        if (!this.rowIndex) return; // skip first row if needed 
        var $sum_poplnenie=this.cells[5].innerHTML;
        var $agent_komissiya=this.cells[2].innerHTML;
        var $subagent_komissiya=this.cells[4].innerHTML;
        var $sum_agent_komissiya=this.cells[8].innerHTML;                
        var $sum_subagent_komissiya=this.cells[9].innerHTML;
        +$sum_poplnenie;
        +$agent_komissiya;
        +$subagent_komissiya;
        +$sum_agent_komissiya;
        +$sum_subagent_komissiya;
        
        var $agent_bonus = ($sum_poplnenie*$agent_komissiya/100).toFixed(3);
        var $subagent_bonus = ($sum_poplnenie*$subagent_komissiya/100).toFixed(3);
        
        +$agent_bonus;
        +$subagent_bonus;
        
        $(this).find(".agent_bonus").html($agent_bonus);
        $(this).find(".subagent_bonus").html($subagent_bonus);                        
        $(this).find(".last_date").html(endDate);
        $(this).find(".all_agent_bonus").html(parseFloat($agent_bonus)+parseFloat($sum_agent_komissiya));
        $(this).find(".all_subagent_bonus").html(parseFloat($subagent_bonus)+parseFloat($sum_subagent_komissiya));
                                        
    });
    
}


function start_find(endDate) {
    if($('#dt_table_tools3').length) {
        $('#dt_table_tools3').dataTable({
            "aoColumns": [
    						{ "sTitle": "№" },
                            { "sTitle": "Номет телефона"},
    						{ "sTitle": "Комиссия агента в %"},
    						{ "sTitle": "Субагент если есть (его id)"},
    						{ "sTitle": "Комиссия субагента в %", "sClass": "center" },    						
                            { "sTitle": "Сумма пополнения по номеру", "sClass": "center" },
                            { "sTitle": "Сумма бонусов агента", "sClass": "center"},
                            { "sTitle": "Сумма бонусов субагента", "sClass": "center"},
                            { "sTitle": "Бонусы агента", "sClass": "center"},
                            { "sTitle": "Бонусы субагентоа", "sClass": "center"},
                            { "sTitle": "Дата последнего расчета бонусов", "sClass": "center"},
    					],        
            
            "sServerMethod": "POST",        
            "sScrollX": "100%",
            "sScrollXInner": '150%',
            "bScrollCollapse": true,
            "oLanguage": {"sProcessing": "Подождите..."},        
            "sPaginationType": "bootstrap",
            "bDestroy": true,
            "bProcessing": true,
            "bServerSide": true,
            "sAjaxSource": "ajax/_test_server_side.txt",            
            
            "fnServerParams": function (aoData) {                
                aoData.push({
                    "name": "endDate",
                    "value": endDate
                })
                aoData.push({
                    "name": "userId",
                    "value": '16'
                })   
            },
            
            
            "sDom": "R<'dt-top-row'CTlf>r<'dt-wrapper't><'dt-row dt-bottom-row'<'row-fluid'ip>",
            "oTableTools": {
                "aButtons": [
                    "copy",
                    "print",
                    {
                        "sExtends":    "collection",
                        "sButtonText": 'Save <span class="caret" />',
                        "aButtons":    [ "csv", "xls", "pdf" ]
                    }
                ],
                "sSwfPath": "template/js/lib/datatables/extras/TableTools/media/swf/copy_csv_xls_pdf.swf"
            },
            "fnInitComplete": function(oSettings, json) {
                $(this).closest('#dt_table_tools3_wrapper').find('.DTTT.btn-group').addClass('table_tools_group').children('a.btn').each(function(){
                    $(this).addClass('btn-mini btn-inverse');
                });
                $('.ColVis_Button').addClass('btn btn-mini btn-inverse').html('Показать/спрятать колонки');
                $('.DTTT_button_copy span').html('Копировать');
                $('.DTTT_button_print span').html('Печать');
                //$('.DTTT_button_collection span').html('Сохранить');                        
                $('.ColVis').css('right', 450);            
            }
        });
    }
}
-->
</script>